/*
 * Created on 2005-2-28
 * Last modified on 2006-10-01
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.tools;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import sun.misc.BASE64Encoder;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.*;

 
import com.yeqiangwei.util.MD5;
import com.yeqiangwei.util.TypeChange;

/**
 * 字符串操作集合类
 * @author YeQiangWei by 我容易么我
 * Powered by YeQiangWei.com
 */
public class EncodeString{
	
    private int closeWinPlayer = 0; /* 关闭为0则表示打开 */
    private int closeRealPlayer = 0;
    private int closeFlash = 0;
    
 
    @SuppressWarnings("static-access")
	public static void main(String args[]){
    	EncodeString es = new EncodeString();
    	//String s0 = es.encodeString("md5of32","芈芈茶芈芈茶");
   	String s0 = es.encodeString("md5of32","000000");
    	//String s1 = es.ubbReplace("http://box.1ting.com/p-1-665-12.html","^(.*)p-(.*?).html","$1players.jsp?ids=$2");
    	System.out.println(s0);
//    	System.out.println(s1);
    }
    
    
    /**
     * 考虑到中文的字符串长度判断
     * @param str
     * @return
     * com.yeqiangwei.tools
     */
    public static int Glength(String str){
        int i = 0;
        String s = "";
        try {
            s = new String(str.getBytes(),"UTF-8");
            i = s.length();
        } catch (UnsupportedEncodingException e) {
           
        }
        return i;
    }
    
    /**
    * 中英文混和字符串按特定长度截取
    * @param res 中英文混和字符。
    * @param start 截取起始位置。
    * @param length 截取长度。
    * @return res中，从start起length长度的子字符串。
    */
    public static String Gsubstring(String res, int start, int length ,String charSet) {
    	if(charSet==null || charSet.equals("")){
    		charSet = "UTF-8";
    	}
    	if(res==null){
    		return "";
    	}
    	if(res.length()<length){
    		return res;
    	}
    	res = res.trim(); //去掉空格
        if(start<1){
            start=1;
        }
        int i_Start,i_Len ,i,j,ilenByte,i_S,i_L;
        i_Start= 0;
        i_S =0;
        i_Len=0;
        i_L =0;
        try {
            byte[] resBytes = res.getBytes(charSet);
            ilenByte =resBytes.length ;
        
            for ( i = 0; i < ilenByte; i++) {
                i_Start = i_Start+1;
                if (i_Start <=start) {i_S = i_S+1;}
                
                if (i_Start >=start){
                    i_Len=i_Len+1; 
                    i_L = i_L +1;
                } 
                
                if (resBytes[i] <0 ) {
                    i = i+2;
                    i_Start = i_Start +1;
                    if (i_Start <start) {i_S = i_S+2;}
                    if (i_Start >=start){
                            i_Len=i_Len+1;
                            i_L=i_L+2;
                    }
                }
            
                if (i_Len >=length) i =ilenByte;
            }
    
        byte[] dest = new byte[i_L];
    
        for ( j = 0; j < i_L;j++) {
            dest[j] = resBytes[i_S + j-1];
        }
    
        return new String(dest, charSet);
    
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
        
    }
    /**
     * codeType 加密方式， txt加密字符串
     */
    public static String encodeString(String codeType, String txt){
        if(codeType.equals("md5of16")){
            MD5 m = new MD5();
            return m.getMD5ofStr16(txt);
        }else if(codeType.equals("md5of32")){  
            MD5 m = new MD5();
            return m.getMD5ofStr(txt);
        }else{
            try {
                MessageDigest gv = MessageDigest.getInstance(codeType);
                gv.update(txt.getBytes());
                return new BASE64Encoder().encode(gv.digest());
            }
            catch(java.security.NoSuchAlgorithmException e) {
            	return null;
            }
        }
    }

    
    private  String replaces(String src, String fnd, String rep){
        if(src==null || src.equals("")){
            return "";
        }
        if (src == null || src.equals("")){
            return "";
        }
        String dst = src;
        int idx = dst.indexOf(fnd);
        while (idx >= 0){
            dst = dst.substring(0, idx) + rep + dst.substring(idx + fnd.length(), dst.length());
            idx = dst.indexOf(fnd, idx + rep.length());
        }
        return dst;
    }
    
   
    public static String codeColor(String str)
    {
        if(str==null) return "";
        str = str.replace(" ","");
        str = ubbPattern(str, "&quot;(.*?)&quot;","<span style=color:#2A00FF;>&quot;$1&quot;</span>");
        str = ubbPattern(str, "\\/\\*(.*?)\\*/","<span style=color:#3F7F5F;>/*$1*/</span>");
        str = ubbPattern(str, "\\/\\/(.*?)\\<br/>","<span style=color:#3F7F5F;>//$1</span><br/>");
        str = ubbPattern(str,"private&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">private&nbsp;</span>");
        str = ubbPattern(str,"protected&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">protected&nbsp;</span>");
        str = ubbPattern(str,"public&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">public&nbsp;</span>");
        str = ubbPattern(str,"static&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">static&nbsp;</span>");
        str = ubbPattern(str,"return&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">return&nbsp;</span>");
        str = ubbPattern(str,"try","<span style=\"color:#7F0055; font-weight: bold;\">try</span>");
        str = ubbPattern(str,"catch","<span style=\"color:#7F0055; font-weight: bold;\">catch</span>");
        str = ubbPattern(str,"finally","<span style=\"color:#7F0055; font-weight: bold;\">finally</span>");
        str = ubbPattern(str,"package","<span style=\"color:#7F0055; font-weight: bold;\">package</span>");
         
        
        str = ubbPattern(str,"null","<span style=\"color:#7F0055; font-weight: bold;\">null</span>");
        str = ubbPattern(str,"short&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">short&nbsp;</span>");
        str = ubbPattern(str,"int&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">int&nbsp;</span>");
        str = ubbPattern(str,"double&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">double&nbsp;</span>");
        str = ubbPattern(str,"byte&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">byte&nbsp;</span>");
        str = ubbPattern(str,"long&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">long&nbsp;</span>");
        str = ubbPattern(str,"final&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">final&nbsp;</span>");
        str = ubbPattern(str,"new&nbsp;","<span style=\"color:#7F0055; font-weight: bold;\">new&nbsp;</span>");
        str = ubbPattern(str,"false","<span style=\"color:#7F0055; font-weight: bold;\">false</span>");
        str = ubbPattern(str,"true","<span style=\"color:#7F0055; font-weight: bold;\">true</span>");
        
        str = ubbPattern(str,"while\\(","<span style=\"color:#7F0055; font-weight: bold;\">while</span>(");
        str = ubbPattern(str,"for\\(","<span style=\"color:#7F0055; font-weight: bold;\">for</span>(");
        str = ubbPattern(str,"switch","<span style=\"color:#7F0055; font-weight: bold;\">switch</span>");
        str = ubbPattern(str,"if\\(","<span style=\"color:#7F0055; font-weight: bold;\">if</span>(");
        str = ubbPattern(str,"else","<span style=\"color:#7F0055; font-weight: bold;\">else</span>");
        str = ubbPattern(str,"this\\.","<span style=\"color:#7F0055; font-weight: bold;\">this</span>.");
        str = ubbPattern(str,"function\\(","<span style=\"color:#7F0055; font-weight: bold;\">function</span>(");
        str = ubbPattern(str,"document.","<span style=\"color:#7F0055; font-weight: bold;\">document</span>.");

        return str; 
    }
    
    /**
     * 标记可运行代码
     * @param src
     * @return
     */
    private static String htmlRun(String src){
        if(src==null) return "";
        String str = "";
        str = matcherCodeColor(src, "\\[code\\](.*?)\\[/code]");
        str = ubbPattern(str, "\\[code\\](.*?)\\[/code]","<table align=center bgcolor=\"#BAD5EF\" width=\"98%\" border=0 cellpadding=4 cellspacing=1>"
        +"<form><tr><td bgcolor=\"#E6EEF7\" height=\"25\"  style=\"font-size: 12px\">程序代码：</td></tr><tr><td bgcolor=\"#ffffff\" style=\"font-size: 12px\">"
        //"<textarea cols=\"60\" rows=\"10\" id=\"gv123\">"
        + ("$1")
        +"</td></tr></form></table>");
        return str;
    }
    
    /**
     * 用于HTML字符串反向替换
     * @param src
     * @return
     * com.yeqiangwei.tools
     */
    public  static String unHtmlEncoder(String src) {
        if (src == null || src.equals("")){
            return "";
        }
        String unHtmlEncode = new String(src);
        unHtmlEncode = unHtmlEncode.replace("&lt;","<");
        unHtmlEncode = unHtmlEncode.replace("&gt;",">"); 
        unHtmlEncode = unHtmlEncode.replace("&quot;","\"");   
        unHtmlEncode = unHtmlEncode.replace("&#039;","'");
        unHtmlEncode = unHtmlEncode.replace("&nbsp;"," ");       
        unHtmlEncode = unHtmlEncode.replace("<br/>","\r\n");
        unHtmlEncode = unHtmlEncode.replace("<br/>","\r");       
        unHtmlEncode = unHtmlEncode.replace("<br/>","\n");
        return unHtmlEncode;
    }
    
    /**
     * 用于HTML字符串替换
     * @param src
     * @return
     * com.yeqiangwei.tools
     */
    public static String htmlEncoder(String src) {
        if (src == null || src.equals("")){
            return "";
        }    
        String htmlencode = new String(src);
        htmlencode = htmlencode.replace("&","&amp;");
        htmlencode = htmlencode.replace("<","&lt;");
        htmlencode = htmlencode.replace(">","&gt;"); 
        htmlencode = htmlencode.replace("\"","&quot;");   
        htmlencode = htmlencode.replace("'","&#039;");
        htmlencode = htmlencode.replace(" ","&nbsp;");       
        htmlencode = htmlencode.replace("\r\n","<br/>");
        htmlencode = htmlencode.replace("\r","<br/>");       
        htmlencode = htmlencode.replace("\n","<br/>");
        return htmlencode;
    }
    
	/**
	 * 转换为XML编码
	 * @param src
	 * @return
	 * com.yeqiangwei.tools
	 */
    public String xmlEncoder(String src){
        if (src == null || src.equals("")){
            return "";
        }
        String xmlencode = src;
        xmlencode = replaces(xmlencode, "&",  "&amp;");
        xmlencode = replaces(xmlencode, "<",  "&lt;");
        xmlencode = replaces(xmlencode, ">",  "&gt;");
        xmlencode = replaces(xmlencode, "\"", "&quot;");
        xmlencode = replaces(xmlencode, "\'", "&acute;");
        return xmlencode;
    }
    
    public String ubbSimple(String str){
        if(str==null || str.equals("")){
            return "";
        }
        str = ubbPattern(str, "\\[url\\](.*?)\\[/url\\]","<a href=\"$1\" target=\"_blank\">$1</a>");
        str = ubbPattern(str, "\\[url=(.*?)\\](.*?)\\[/url\\]","<a href=\"$1\" target=\"_blank\">$2</a>");
        str = ubbPattern(str, "\\[img\\](.*?)\\[/img\\]","<a href=\"$1\" target=\"_blank\"><img " +
                " onload=\"javascript:if(this.width > screen.width-350){this.width = screen.width-350};\" " + 
                " onerror=\"javascript:this.src='/club/images/imgErr.gif'\" src=\"$1\" border=\"0\" /></a>"); 
        str = ubbPattern(str,"\\[center\\](.*?)\\[/center\\]","<center>$1</center>");
        str = ubbPattern(str,"\\[b\\](.*?)\\[/b\\]","<strong>$1</strong>");
        str = ubbPattern(str,"\\[i\\](.*?)\\[/i\\]","<em>$1</em>");
        str = ubbPattern(str,"\\[u\\](.*?)\\[/u\\]","<em>$1</em>");
        str = ubbPattern(str, "\\[color=(.*?)\\](.*?)\\[/color\\]","<span style=color:$1>$2</span>");
        str = ubbPattern(str, "\\[ClubFace_(\\d*)\\]","<img src=\"images/YeQiangWeiFace/$1.gif\">");
        str = ubbPattern(str, "\\[size=1](.*?)\\[/size\\]","<font size=\"1\">$1</font>");
        str = ubbPattern(str, "\\[size=2](.*?)\\[/size\\]","<font size=\"2\">$1</font>");
        str = ubbPattern(str, "\\[size=3](.*?)\\[/size\\]","<font size=\"3\">$1</font>");
        str = ubbPattern(str, "\\[size=4](.*?)\\[/size\\]","<font size=\"4\">$1</font>");
        str = ubbPattern(str, "\\[size=5](.*?)\\[/size\\]","<font size=\"5\">$1</font>");
        str = ubbPattern(str, "\\[size=6](.*?)\\[/size\\]","<font size=\"6\">$1</font>");
        str = ubbPattern(str, "\\[size=7](.*?)\\[/size\\]","<font size=\"7\">$1</font>");
        str = ubbPattern(str, "\\[font=(.*?)](.*?)\\[/font\\]","<font face=\"$1\">$2</font>");
     	return str;
    }
    
    public String ubbEncoder(String str){
        if(str==null || str.equals("")){
            return "";
        } 
        /**
         * 为了不合正则表达式关键字符冲突替换$为其他字符
         * 然后再最下面再替换回去
         */
        str = str.replace("$","(@#%)"); 
        str = ubbPattern(str,"\\","\\\\");
       
        List list = matcherList(str,"\\[(.*?)\\](.*?)\\[/(.*?)\\]");
        for(int i=0;i<list.size();i++){
        	String s = TypeChange.objOfString(list.get(i));
        	str = str.replace(s,s.replace("\\","\\\\"));
        }
        str = ubbPattern(str,"\\[move\\](.*?)\\[/move\\]","<marquee scrollamount=\"1\" delay=\"3\" onmouseout='start()' onmouseover='stop()'>$1</marquee>");
        str = this.ubbSimple(str);        
        str = ubbPattern(str,"\\[quote\\](.*?)\\[/quote\\]","<table align=center bgcolor=\"#BAD5EF\" width=\"98%\" border=0 cellpadding=4 cellspacing=1>" +
                                "<tr><td bgcolor=\"#E6EEF7\" height=\"25\"  style=\"font-size: 12px\"><strong>以下内容为引用内容</strong>：</td></tr><tr><td bgcolor=\"#ffffff\" style=\"font-size: 12px\">$1</td></tr></table>");
        
        str = ubbPattern(str,"\\[quote=(.*?)\\](.*?)\\[/quote\\]","<table align=center bgcolor=\"#BAD5EF\" width=\"98%\" border=0 cellpadding=4 cellspacing=1>" +
        "<tr><td bgcolor=\"#E6EEF7\" height=\"25\"  style=\"font-size: 12px\"><strong>$1 说：</strong></td></tr><tr><td bgcolor=\"#ffffff\" style=\"font-size: 12px\">$2</td></tr></table>");
        
        StringBuffer sb = new StringBuffer("");
        
        /* flash player start */
        if(closeFlash==0){
	        sb.append("<script language=\"javascript\">");
	        sb.append("EncodeString_flash(500,400,'$1');");
	        sb.append("</script>");
	        str = ubbPattern(str, "\\[flash\\](.*?)\\[/flash\\]",sb.toString());
	        str = ubbPattern(str, "\\[swf\\](.*?)\\[/swf\\]",sb.toString());
	        sb.delete(0,sb.length());
	        
	        sb.append("<script language=\"javascript\">");
	        sb.append("EncodeString_flash($1,$2,'$3');");
	        sb.append("</script>");
	        str = ubbPattern(str, "\\[flash=*([\\d]*),*([\\d]*)\\](.*?)\\[/flash\\]",sb.toString());
	        str = ubbPattern(str, "\\[swf=*([\\d]*),*([\\d]*)\\](.*?)\\[/swf\\]",sb.toString());
	        sb.delete(0,sb.length()); 
        }
        /* flash player end */
        
        /** real palyer start */
        if(closeRealPlayer==0){
        	sb.append("<script language=\"javascript\">");
	        sb.append("YeQiangWeiPlayer_real(450,350,-1,'$1');");
	        sb.append("</script>");
	        str = ubbPattern(str, "\\[real\\](.*?)\\[/real\\]",sb.toString());
	        sb.delete(0,sb.length()); 
	        
	        sb.append("<script language=\"javascript\">");
	        sb.append("YeQiangWeiPlayer_real($1,$2,-1,'$3');");
	        sb.append("</script>");        
	        str = ubbPattern(str, "\\[real=*([\\d]*),*([\\d]*)\\](.*?)\\[/real\\]",sb.toString());
	        sb.delete(0,sb.length()); 
	
	        sb.append("<script language=\"javascript\">");
	        sb.append("YeQiangWeiPlayer_real($1,$2,$3,'$4');");
	        sb.append("</script>");    
	        str = ubbPattern(str, "\\[real=*([\\d]*),*([\\d]*),(-1|0)\\](.*?)\\[/real\\]",sb.toString());
	        sb.delete(0,sb.length()); 
        }
        /** real palyer end */
        
        /** windows palyer start */
        if(closeWinPlayer==0){    
	        sb.append("<script language=\"javascript\">");
	        sb.append("YeQiangWeiPlayer_windows(450,350,1,'$1');");
	        sb.append("</script>"); 
	        str = ubbPattern(str, "\\[video\\](.*?)\\[/video\\]",sb.toString());
	        sb.delete(0,sb.length());
        	
        	
	        sb.append("<script language=\"javascript\">");
	        sb.append("YeQiangWeiPlayer_windows($1,$2,1,'$3');");
	        sb.append("</script>");  
	        str = ubbPattern(str, "\\[video=*([\\d]*),*([\\d]*)\\](.*?)\\[/video\\]",sb.toString());
	        sb.delete(0,sb.length());
	        
	        sb.append("<script language=\"javascript\">");
	        sb.append("YeQiangWeiPlayer_windows($1,$2,$3,'$4');");
	        sb.append("</script>");  
	        str = ubbPattern(str, "\\[video=*([\\d]*),*([\\d]*),*([\\d]*)\\](.*?)\\[/video\\]",sb.toString());
	        sb.delete(0,sb.length());
        }
        /** windows palyer end */
        
        sb = null;
        str = htmlRun(str);
        str = str.replace("(@#%)","$");
        return str;
    }
    
    /**
     * 代码内容的色彩替换
     * @param str
     * @param cp
     * @param s
     * @return
     */    
    public static String matcherCodeColor(String str, String cp){
        if(str==null || str.equals("")){
            return "";
        }
        String txt = new String();
        if(str!=null && !str.equals("")){
            txt = str;
            Pattern p = Pattern.compile(cp,2); //参数2表示大小写不区分
            Matcher m = p.matcher(txt);
            StringBuffer sb = new StringBuffer();
            boolean result = m.find();
            String temp = "";
            //使用循环将句子里所有匹配的内容找出并替换再将内容加到sb里
            while(result) {
                temp = m.group();
                temp = codeColor(temp);
                m.appendReplacement(sb,temp);
                //继续查找下一个匹配对象
                result = m.find();
            }
            //最后调用appendTail()方法将最后一次匹配后的剩余字符串加到sb里；
            m.appendTail(sb);
            txt = String.valueOf(sb);
        }else{
            txt = "";
        }
        return txt;       
    }
    
    /**
     * 正则匹配并完成替换过程
     * @param str 要检索的字符串
     * @param cp 正则匹配条件字符串
     * @param mc 要替换成的字符串
     * @return
     */
    public static String ubbPattern(String str, String cp, String mc){
        if(str==null || str.equals("")){
            return "";
        }
        String txt = new String();
        txt = str;
        if(str!=null && !str.equals("")){
            txt = str;
            try{
	            Pattern p = Pattern.compile(cp,2); //参数2表示大小写不区分
	            Matcher m = p.matcher(txt);
	            txt = m.replaceAll(mc);
	        }catch(Exception e){
            	
            }
        }else{
            txt = "";
        }
        return txt;       
    }

    public static String ubbReplace(String str, String cp, String mc){
        if(str==null || str.equals("")){
            return "";
        }
        String txt = new String();
        txt = str;
        if(str!=null && !str.equals("")){
            txt = str;
            try{
	            Pattern p = Pattern.compile(cp,2); //参数2表示大小写不区分
	            Matcher m = p.matcher(txt);
	            txt = m.replaceAll(mc);
	        }catch(Exception e){
            	
            }
        }else{
            txt = "";
        }
        return txt;        
    }
    
    /*
    public static void main(String args[]){
    	String s = "rthfghfger[ti:献世]56rtyhrthfg";
    	String p = EncodeString.matcherStr(s,"(?<=ti:)[^\\]]*","");
    	System.out.println(p);
    }
    */
    /*
    public static String ubbPattern(String str, String cp, String mc){
        if(str==null || str.equals("")){
            return "";
        }
        String txt = new String();
        txt = str;
        if(str!=null && !str.equals("")){
            txt = str;
            txt = str.replaceAll(str,cp);
        }else{
            txt = "";
        }
        return txt;   
    }
    */
    
    /**
     * 循环找出匹配内容
     * @param str
     * @param cp
     * @param s 循环匹配内容间隔符
     * @return
     * 2005-12-11 18:45:25 Made In YeQiangWei
     * com.yeqiangwei.tools
     */
    public static String matcherStr(String str, String cp, String s){
        if(str==null || str.equals("")){
            return "";
        }
        String txt = new String();
        txt = str;
        if(str!=null && !str.equals("")){
            txt = str;
            Pattern p = Pattern.compile(cp,2); //参数2表示大小写不区分
            Matcher m = p.matcher(txt);
            StringBuffer sb = new StringBuffer();
            int i=0;
            boolean result = m.find();
            //使用循环将句子里所有匹配的内容找出并替换再将内容加到sb里
            while(result) {
                i++;
                sb.append(m.group());
                sb.append(s);
                //继续查找下一个匹配对象
                result = m.find();
            }
            txt = String.valueOf(sb);
        }else{
            txt = "";
        }
        return txt;       
    }
    
    /**
     * 指定第几次匹配才执行替换
     * @param str
     * @param cp
     * @param s
     * @param loop 指定第几次, 0表示循环所有匹配内
     * @return
     * 2005-12-11 18:46:30 Made In YeQiangWei
     * com.yeqiangwei.tools
     */
    public static String matcherStr(String str, String cp
    		, String s, int loop)
    {
        if(str==null || str.equals("")){
            return "";
        }
        String txt = new String();
        txt = str;
        if(str!=null && !str.equals("")){
            txt = str;
            Pattern p = Pattern.compile(cp,2); //参数2表示大小写不区分
            Matcher m = p.matcher(txt);
            StringBuffer sb = new StringBuffer();
            int i=0;
            boolean result = m.find();
            //使用循环将句子里所有匹配的内容找出并替换再将内容加到sb里
            while(result) {
                i++;
                if(loop==i){
	                sb.append(m.group());
	                sb.append(s);
                }else if(loop==0){
	                sb.append(m.group());
	                sb.append(s);
	                //继续查找下一个匹配对象
	                result = m.find();
                }else{
                    //继续查找下一个匹配对象
                    result = m.find();
                }
            }    
            txt = String.valueOf(sb);
        }else{
            txt = "";
        }
        return txt;       
    }
    
    /**
     * 循环找出匹配内容
     * @param str
     * @param cp
     * @return
     * 2005-12-11 18:45:25 Made In YeQiangWei
     * com.yeqiangwei.tools
     */
    @SuppressWarnings("unchecked")
	public static List matcherList(String str, String cp){
        if(str==null || str.equals("")){
            return null;
        }
        List list = new ArrayList();
        String txt = new String();
        txt = str;
        if(str!=null && !str.equals("")){
            txt = str;
            Pattern p = Pattern.compile(cp,2); //参数2表示大小写不区分
            Matcher m = p.matcher(txt);
            boolean result = m.find();
            //使用循环将句子里所有匹配的内容找出并替换再将内容加到sb里
            while(result) {
                list.add(m.group());
                //继续查找下一个匹配对象
                result = m.find();
            }
        }else{
           //list = null;
        }
        return list;       
    }
    
    /* windows播放器开始 */
    public String YeQiangWeiPlayer_windows(String w, String h, String auto, String path)
    {
    	StringBuffer sb = new StringBuffer("");
    	int rom = (int) Math.random();
    	rom = rom * 1000000000;
    	rom = (int) Math.ceil(rom);
    	sb.append("<OBJECT align=\"middle\" classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" ");
    	sb.append(" id=\"MediaPlayer");
    	sb.append(rom);
    	sb.append("\" ");
        sb.append(" width=\""+w+"\" height=\""+h+"\">");
        sb.append("<param name=\"autostart\" value='"+auto+"'>");
        sb.append("<param name=\"ShowStatusBar\" value=\"-1\">");
        sb.append("<param name=\"loop\" value=\"true\">");
        sb.append("<param name=\"Filename\" value=\""+path+"\">");
        sb.append("</OBJECT>");     
        sb.append("<br>\n<script language=javascript>\n");
        sb.append("function media_full"+ rom +"(){\n");
        sb.append("alert('将进入全屏模式,按Esc键退出全屏!若影片未加载成功将无法进入全屏!');\n");
        sb.append("document.MediaPlayer"+ rom +".DisplaySize=3;");
        sb.append("\n}</script>\n");
        sb.append("<input type=\"button\" name=\"mplayer\""+ rom +"\" onclick=\"javascript:media_full"+ rom +"()\" value=\"全屏播放\" class=\"btn\" />"); 
    	return sb.toString();
    }
    /* windows播放器结束 */
    
	public void setCloseRealPlayer(int closeRealPlayer) {
		this.closeRealPlayer = closeRealPlayer;
	}

	public void setCloseWinPlayer(int closeWinPlayer) {
		this.closeWinPlayer = closeWinPlayer;
	}

	public int getCloseFlash() {
		return closeFlash;
	}

	public void setCloseFlash(int closeFlash) {
		this.closeFlash = closeFlash;
	}

	public int getCloseRealPlayer() {
		return closeRealPlayer;
	}

	public int getCloseWinPlayer() {
		return closeWinPlayer;
	}
 
	
}